package com.woniu.admin.configs;

import com.woniu.admin.util.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Resource
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> list = new ArrayList<>();
        list.add("/css/**");
        list.add("/js/**");
        list.add("/imgs/**");
        list.add("/captcha/getVerifyCodeImage");
        list.add("/user/login");
        list.add("/login.html");
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**").
                excludePathPatterns(list);
    }
}
